package 算法.NiuKe.JZ;

/**
 * @author:谢君臣
 * @Date:2021/3/1620:34
 * @version:1.0
 * @function:
 * 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
 * 保证base和exponent不同时为0
 */
public class JZ12 {
    public static void main(String[] args) {

    }
    public double Power(double base, int exponent) {
        double pow = Math.pow(base, exponent);
        return pow;
    }
    public double Power1(double base, int exponent) {
        if( exponent < 0 ){
            base =  1/ base ;
            exponent = - exponent ;
        }
        double result = 1.0;
        for( int i =0;i<exponent;i++){
            result *= base ;
        }
        return result;
    }
}
